iOS-学习之MPMediaItem

iOS媒体库文件信息的Item。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
NS_ASSUME_NONNULL_BEGIN
@class NSImage, UIImage, MPMediaItemArtwork;
typedef NS_OPTIONS(NSUInteger, MPMediaType) {
// audio
MPMediaTypeMusic = 1 << 0, // 音乐
MPMediaTypePodcast = 1 << 1, // 音频播客
MPMediaTypeAudioBook = 1 << 2, // 音频书
MPMediaTypeAudioITunesU MP_API(ios(5.0), macos(10.12.2)) = 1 << 3, // iTunes U音频课
MPMediaTypeAnyAudio = 0x00ff, // 任何类型的音频
// video
MPMediaTypeMovie MP_API(ios(5.0), macos(10.12.2)) = 1 << 8, // 电影
MPMediaTypeTVShow MP_API(ios(5.0), macos(10.12.2)) = 1 << 9, // 电视节目
MPMediaTypeVideoPodcast MP_API(ios(5.0), macos(10.12.2)) = 1 << 10, // 播客视频
MPMediaTypeMusicVideo MP_API(ios(5.0), macos(10.12.2)) = 1 << 11, // 音乐视频
MPMediaTypeVideoITunesU MP_API(ios(5.0), macos(10.12.2)) = 1 << 12, // iTunes U视频课
MPMediaTypeHomeVideo MP_API(ios(7.0), macos(10.12.2)) = 1 << 13, // 家庭视频
MPMediaTypeAnyVideo MP_API(ios(5.0), macos(10.12.2)) = 0xff00, // 任何视频
MPMediaTypeAny = ~0UL // 未指定的媒体视频内容
} MP_API(ios(3.0), tvos(9.0), macos(10.12.2));
// An MPMediaItem represents a single piece of media in an MPMediaLibrary.
// Media items have a unique identifier which persists across application launches.
MP_API(ios(3.0))
MP_PROHIBITED(tvos, macos)
@interface MPMediaItem : MPMediaEntity
#pragma mark - Properties
// Properties marked filterable can also be used to build MPMediaPropertyPredicates (see MPMediaQuery.h).
// 获取媒体项持久标识符
MP_EXTERN NSString * const MPMediaItemPropertyPersistentID MP_API(ios(4.2), macos(10.12.2)); // filterable
@property (nonatomic, readonly) MPMediaEntityPersistentID persistentID MP_API(ios(5.0));
// 获取媒体类型
MP_EXTERN NSString * const MPMediaItemPropertyMediaType; // filterable
@property (nonatomic, readonly) MPMediaType mediaType MP_API(ios(7.0));
// 获取媒体项目的标题
MP_EXTERN NSString * const MPMediaItemPropertyTitle; // filterable
@property (nonatomic, readonly, nullable) NSString *title MP_API(ios(7.0));
// 获取专辑名称
MP_EXTERN NSString * const MPMediaItemPropertyAlbumTitle; // filterable
@property (nonatomic, readonly, nullable) NSString *albumTitle MP_API(ios(7.0));
// 获取专辑项目持久标识符
MP_EXTERN NSString * const MPMediaItemPropertyAlbumPersistentID MP_API(ios(4.2), macos(10.12.2)); // filterable
@property (nonatomic, readonly) MPMediaEntityPersistentID albumPersistentID MP_API(ios(8.0));
// 获取媒体或专辑的表演艺术家
MP_EXTERN NSString * const MPMediaItemPropertyArtist; // filterable
@property (nonatomic, readonly, nullable) NSString *artist MP_API(ios(7.0));
// 获取艺术家持久标识符
MP_EXTERN NSString * const MPMediaItemPropertyArtistPersistentID MP_API(ios(4.2), macos(10.12.2)); // filterable
@property (nonatomic, readonly) MPMediaEntityPersistentID artistPersistentID MP_API(ios(8.0));
// 专辑的主要表演艺术家
MP_EXTERN NSString * const MPMediaItemPropertyAlbumArtist; // filterable
@property (nonatomic, readonly, nullable) NSString *albumArtist MP_API(ios(7.0));
// 获取专辑的主要表演艺术家的持久标识符
MP_EXTERN NSString * const MPMediaItemPropertyAlbumArtistPersistentID MP_API(ios(4.2), macos(10.12.2)); // filterable
@property (nonatomic, readonly) MPMediaEntityPersistentID albumArtistPersistentID MP_API(ios(8.0));
// 获取媒体项目类型
MP_EXTERN NSString * const MPMediaItemPropertyGenre; // filterable
@property (nonatomic, readonly, nullable) NSString *genre MP_API(ios(7.0));
// 获取媒体项目类型的持久标识符
MP_EXTERN NSString * const MPMediaItemPropertyGenrePersistentID MP_API(ios(4.2), macos(10.12.2)); // filterable
@property (nonatomic, readonly) MPMediaEntityPersistentID genrePersistentID MP_API(ios(8.0));
// 获取媒体音乐的作曲家
MP_EXTERN NSString * const MPMediaItemPropertyComposer; // filterable
@property (nonatomic, readonly, nullable) NSString *composer MP_API(ios(7.0));
// 获取媒体音乐的作曲家的持久标识符
MP_EXTERN NSString * const MPMediaItemPropertyComposerPersistentID MP_API(ios(4.2), macos(10.12.2)); // filterable
@property (nonatomic, readonly) MPMediaEntityPersistentID composerPersistentID MP_API(ios(8.0));
// 获取媒体项目持续播放时长
MP_EXTERN NSString * const MPMediaItemPropertyPlaybackDuration;
@property (nonatomic, readonly) NSTimeInterval playbackDuration MP_API(ios(7.0));
// 媒体项目的曲目编号
MP_EXTERN NSString * const MPMediaItemPropertyAlbumTrackNumber;
@property (nonatomic, readonly) NSUInteger albumTrackNumber MP_API(ios(7.0));
// 包含媒体项的相册中的曲目数
MP_EXTERN NSString * const MPMediaItemPropertyAlbumTrackCount;
@property (nonatomic, readonly) NSUInteger albumTrackCount MP_API(ios(8.0));
// 媒体项的磁盘号码,用于多个唱片集的一部分的媒体项
MP_EXTERN NSString * const MPMediaItemPropertyDiscNumber;
@property (nonatomic, readonly) NSUInteger discNumber MP_API(ios(7.0));
// 包含媒体项的相册中的磁盘数
MP_EXTERN NSString * const MPMediaItemPropertyDiscCount;
@property (nonatomic, readonly) NSUInteger discCount MP_API(ios(8.0));
// 媒体项目的原图图像
MP_EXTERN NSString * const MPMediaItemPropertyArtwork MP_API(ios(3.0), macos(10.13.2));
@property (nonatomic, readonly, nullable) MPMediaItemArtwork *artwork MP_API(ios(7.0));
// 是否有歌词或语言
MP_EXTERN NSString * const MPMediaItemPropertyIsExplicit MP_API(ios(7.0), macos(10.12.2));
@property (nonatomic, readonly, getter = isExplicitItem) BOOL explicitItem MP_API(ios(10.0));
// 媒体项目的歌词
MP_EXTERN NSString * const MPMediaItemPropertyLyrics;
@property (nonatomic, readonly, nullable) NSString *lyrics MP_API(ios(8.0));
// 媒体项目是否是编译的一部分
MP_EXTERN NSString * const MPMediaItemPropertyIsCompilation; // filterable
@property (nonatomic, readonly, getter = isCompilation) BOOL compilation MP_API(ios(8.0));
// 媒体项目发布日期
MP_EXTERN NSString * const MPMediaItemPropertyReleaseDate MP_API(ios(4.0), macos(10.12.2));
@property (nonatomic, readonly, nullable) NSDate *releaseDate MP_API(ios(7.0));
// 媒体项目每分钟的音乐节拍数
MP_EXTERN NSString * const MPMediaItemPropertyBeatsPerMinute MP_API(ios(4.0), macos(10.12.2));
@property (nonatomic, readonly) NSUInteger beatsPerMinute MP_API(ios(8.0));
// 媒体项目的文本信息
MP_EXTERN NSString * const MPMediaItemPropertyComments MP_API(ios(4.0), macos(10.12.2));
@property (nonatomic, readonly, nullable) NSString *comments MP_API(ios(8.0));
// 指向媒体项的url
MP_EXTERN NSString * const MPMediaItemPropertyAssetURL MP_API(ios(4.0), macos(10.12.2));
@property (nonatomic, readonly, nullable) NSURL *assetURL MP_API(ios(8.0));
// 媒体项是否是iCloud音乐库项目
MP_EXTERN NSString * const MPMediaItemPropertyIsCloudItem MP_API(ios(6.0), macos(10.12.2)); // filterable
@property (nonatomic, readonly, getter = isCloudItem) BOOL cloudItem MP_API(ios(8.0));
// 媒体项目是否有保护权
MP_EXTERN NSString * const MPMediaItemPropertyHasProtectedAsset MP_API(ios(9.2), macos(10.12.2)); // filterable
@property (nonatomic, readonly, getter = hasProtectedAsset) BOOL protectedAsset MP_API(ios(9.2));
// 播客的标题
MP_EXTERN NSString * const MPMediaItemPropertyPodcastTitle; // filterable
@property (nonatomic, readonly, nullable) NSString *podcastTitle MP_API(ios(7.0));
// 音频播客的持久标识符
MP_EXTERN NSString * const MPMediaItemPropertyPodcastPersistentID MP_API(ios(4.2), macos(10.12.2)); // filterable
@property (nonatomic, readonly) MPMediaEntityPersistentID podcastPersistentID MP_API(ios(8.0));
// 媒体项目的播放次数
MP_EXTERN NSString * const MPMediaItemPropertyPlayCount; // filterable
@property (nonatomic, readonly) NSUInteger playCount MP_API(ios(7.0));
// 用户跳过该项目的次数
MP_EXTERN NSString * const MPMediaItemPropertySkipCount;
@property (nonatomic, readonly) NSUInteger skipCount MP_API(ios(7.0));
// 用户的评级 [1……5]
MP_EXTERN NSString * const MPMediaItemPropertyRating;
@property (nonatomic, readonly) NSUInteger rating MP_API(ios(7.0));
// 上次播放媒体项目的日期
MP_EXTERN NSString * const MPMediaItemPropertyLastPlayedDate;
@property (nonatomic, readonly, nullable) NSDate *lastPlayedDate MP_API(ios(7.0));
// 媒体项目分组信息
MP_EXTERN NSString * const MPMediaItemPropertyUserGrouping MP_API(ios(4.0), macos(10.12.2));
@property (nonatomic, readonly, nullable) NSString *userGrouping MP_API(ios(8.0));
// 用户最近出现在媒体项目中的位置
MP_EXTERN NSString * const MPMediaItemPropertyBookmarkTime MP_API(ios(6.0), macos(10.12.2));
@property (nonatomic, readonly) NSTimeInterval bookmarkTime MP_API(ios(7.0));
// 媒体项目的添加日期
MP_EXTERN NSString * const MPMediaItemPropertyDateAdded MP_API(ios(10.0), macos(10.12.2));
@property (nonatomic, readonly) NSDate *dateAdded MP_API(ios(10.0));
// Matches the id used by MPMusicPlayerController to enqueue store tracks
MP_EXTERN NSString * const MPMediaItemPropertyPlaybackStoreID MP_API(ios(10.3));
@property (nonatomic, readonly) NSString *playbackStoreID MP_API(ios(10.3));
@end
//-----------------------------------------------------
MP_API(ios(3.0), tvos(9.0), macos(10.12.2))
@interface MPMediaItemArtwork : NSObject
#if TARGET_OS_IPHONE
// 初始化艺术品媒体项目图片的大小
- (instancetype)initWithBoundsSize:(CGSize)boundsSize requestHandler:(UIImage *(^)(CGSize size))requestHandler NS_DESIGNATED_INITIALIZER MP_API(ios(10.0), tvos(10.0));
// Returns the artwork image for an item at a given size (in points).
- (nullable UIImage *)imageWithSize:(CGSize)size;
#else
- (instancetype)initWithBoundsSize:(CGSize)boundsSize requestHandler:(NSImage *(^)(CGSize size))requestHandler NS_DESIGNATED_INITIALIZER MP_API(ios(10.12.2));
// Returns the artwork image for an item at a given size (in points).
- (nullable NSImage *)imageWithSize:(CGSize)size MP_API(ios(10.12.2));
#endif
@property (nonatomic, readonly) CGRect bounds; // The bounds of the full size image (in points).
#endif
- (id)init NS_UNAVAILABLE;
@end
NS_ASSUME_NONNULL_END